package com.hnas.ecard.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.hnas.ecard.dao.CommoditDao;
import com.hnas.ecard.mapper.CommoditMapper;
import com.hnas.ecard.orm.Commodit;
import com.hnas.ecard.service.CommoditService;
import com.hnas.ecard.service.dto.DTOCommodit;
import com.hnas.ecard.service.search.DTOCommoditSearch;

@Component("commoditService")
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class CommoditServiceImpl implements CommoditService{

	@Autowired
	private CommoditDao commoditDao;

	@Override
	public DTOCommodit findById(String id) {
		Commodit find = commoditDao.find(id);
		return CommoditMapper.getInstance().mapToValue(find);
	}

	@Override
	public List<Commodit> pageByMrchId(DTOCommoditSearch criteria) {
		return commoditDao.pageByMrchId(criteria);
	}

	@Override
	public Commodit saveOrUpdate(DTOCommodit dto) throws Exception {
		return this.commoditDao.saveOrUpdate(dto);
	}

	@Override
	public boolean deleteById(String id) {
		return this.commoditDao.deleteById(id);
	}
}
